﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AIthin.Neuro
{
    /// <summary>
    /// Model of neuron´s dentrit (output)
    /// </summary>
    [Serializable]
    public class Dendrit
    {
        public float Weight { get; set; }
        public float Signal { get; set; }
        public int ConnectedNeuron { get; set; }
        public int ConnectedAxon { get; set; }
        //public static float SignalRange = 1.0f;
        protected static Random random = new Random();
        public bool Prozessed { get; set; }

        public Dendrit()
        {
            Weight = 0.2f*Convert.ToSingle(random.NextDouble());
            Prozessed = false;
        }
       
        public float Out()
        {
            return Signal * Weight;
        }
        public void Reset()
        {
            Prozessed = false;
            Signal = 0;
        }

        public void weightGrow(float weightDelta)
        {
            Weight += weightDelta;
            if (Weight < -1f) Weight = -1.0f;
            if (Weight > 1f) Weight = 1.0f;
        }
    }
}
